redis.call("select", 1)
local i = 1
local j = 9
repeat
	if(tonumber(ARGV[i]) > 0) then	
		local amount = redis.call('get', KEYS[i])
		if(amount == false) then
			amount = 0
		end
		if(tonumber(amount) >= tonumber(ARGV[i])) then
			return false
		end
	end
i = i + 1
until(i > 8)
	
repeat
	if(tonumber(ARGV[i]) > 0) then
		local budget = redis.call('get', KEYS[i])
		if(budget == false) then
			budget = 0
		end
		if(tonumber(ARGV[i]) - tonumber(budget) < tonumber(ARGV[13])) then
			return false
		end
	end
j = j + 1
until(j > 12)
	
return true





